<%@page import="tu.java.reservation.Ticket"%>
<%@page import="tu.java.reservation.Reservation"%>
<%@page import="java.util.Vector"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>

<%@include file="template/header.jspf" %>

<%String [] ids = request.getParameterValues("reserved");
if(ids!=null && ids.length>0){
String pId = request.getParameter("pId");
Reservation reservation = new Reservation();
User user = (User) session.getAttribute("userObj");
Vector <Ticket> tickets = new Vector<Ticket>();
for(int i=0;i<ids.length;i++){
	Ticket t = new Ticket();
	t.setSeatId(Integer.parseInt( ids[i]));
	tickets.add(t);
}
reservation.setProjectionId(Integer.parseInt(pId));
reservation.setTickets(tickets);
if(reservation.addReservation(user.getUserId())){
%> 	<div style="background-color:green; font-size: 1.4em; color:black; text-align: center;">Успешна резервация!</div>
<%}
else{
%>	<div style="background-color:red; font-size: 1.4em; color:black; text-align: center;">Възникна проблем при резервацията!</div>
<%}
}
else{
%>	<div style="background-color:orange; font-size: 1.4em; color:black; text-align: center;">Не са резервирани места!</div>
<%}%>